/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.ifal.newnews.bd;

import br.edu.ifal.newnews.modelo.Forum;
import br.edu.ifal.newnews.modelo.Usuario;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ifal
 */
public class ForumBD {
    
     public void insereOpiniao(Forum forum) throws SQLException {

        Connection c = new ConexaoBD().abreConexao();

        String sql = "insert into tbForum"
                + "(opiniao,comentario,codigo_cliente)"
                + "values (?,?,?)";

        PreparedStatement stmt = null;

        try {
            stmt = c.prepareStatement(sql);


            stmt.setString(1, forum.getOpiniao());
            stmt.setString(2, forum.getComentario());
            stmt.setInt(3, forum.getCodigo_usuario().getCodigo());
            
             stmt.execute();
            stmt.close();
        } catch (SQLException ex) {
            Logger.getLogger(UsuarioBD.class.getName()).log(Level.SEVERE, null, ex);

        } finally {
            c.close();
        }
    }

  
}
